var FormDefSelector = {
	getView : function(i, c) {
		var g = new Ext.data.JsonStore({
			url : __ctxPath + "/flow/listFormDef.do?Q_status_SN_EQ=1",
			root : "result",
			totalProperty : "totalCounts",
			remoteSort : true,
			fields : [ {
				name : "formDefId",
				type : "int"
			}, "formTitle", "formDesp", "status" ]
		});
		g.setDefaultSort("formDefId", "desc");
		g.load({
			params : {
				start : 0,
				limit : 25
			}
		});
		var d = new Ext.ux.grid.RowActions({
			header : "管理",
			width : 80,
			actions : [ {
				iconCls : "btn-showDetail",
				qtip : "查看",
				style : "margin:0 3px 0 3px"
			} ]
		});
		var a = new Ext.grid.CheckboxSelectionModel({
			singleSelect : true
		});
		var h = new Ext.grid.ColumnModel({
			columns : [ a, new Ext.grid.RowNumberer(), {
				header : "formDefId",
				dataIndex : "formDefId",
				hidden : true
			}, {
				header : "表单标题",
				dataIndex : "formTitle"
			}, {
				header : "描述",
				dataIndex : "formDesp",
				sortable : false
			}, d ],
			defaults : {
				sortable : true,
				menuDisabled : false,
				width : 100
			}
		});
		var b = new Ext.FormPanel({
			id : "FormDefSelectorSearchPanel",
			layout : "hbox",
			region : "north",
			anchor : "98%",
			url : __ctxPath + "/flow/formDef.do",
			height : 40,
			frame : false,
			layoutConfig : {
				padding : "5px",
				align : "middle"
			},
			keys : {
				key : Ext.EventObject.ENTER,
				fn : this.search,
				scope : this
			},
			defaults : {
				xtype : "label",
				margins : {
					top : 4,
					bottom : 4,
					left : 10,
					right : 10
				}
			},
			items : [ {
				text : "表单名称："
			}, {
				anchor : "30%",
				xtype : "textfield",
				name : "Q_formTitle_S_LK",
				maxLength : 128
			}, {
				xtype : "button",
				text : "搜索",
				iconCls : "search",
				handler : this.search,
				scope : this
			} ]
		});
		var e = new Ext.grid.GridPanel({
			id : "FormDefGrid",
			region : "center",
			stripeRows : true,
			store : g,
			trackMouseOver : true,
			disableSelection : false,
			loadMask : true,
			plugins : d,
			cm : h,
			sm : a,
			viewConfig : {
				forceFit : true,
				autoFill : true,
				forceFit : true
			},
			bbar : new HT.PagingBar({
				store : g
			})
		});
		d.on("action", this.onRowAction, this);
		var f = new Ext.Window({
			id : "FormDefSelectorWin",
			title : "流程表单选择",
			iconCls : "menu-form",
			maximizable : true,
			modal : true,
			width : 650,
			height : 400,
			layout : "border",
			items : [ b, e ],
			buttonAlign : "center",
			buttons : [
					{
						text : "确定",
						iconCls : "btn-ok",
						handler : function() {
							var j = Ext.getCmp("FormDefGrid")
									.getSelectionModel().getSelections();
							if (j != null && j.length > 0) {
								if (i != null) {
									i.call(this, j[0].data.formDefId,
											j[0].data.formTitle);
								}
							} else {
								i.call(this, null, null);
							}
							f.close();
						}
					}, {
						text : "取消",
						iconCls : "btn-cancel",
						handler : function() {
							f.close();
						}
					} ]
		});
		return f;
	},
	search : function() {
		var b = Ext.getCmp("FormDefSelectorSearchPanel");
		var a = Ext.getCmp("FormDefGrid");
		if (b.getForm().isValid()) {
			$search({
				searchPanel : b,
				gridPanel : a
			});
		}
	},
	onRowAction : function(c, a, d, e, b) {
		switch (d) {
		case "btn-showDetail":
			this.show(a.data.formDefId);
			break;
		}
	},
	show : function(a) {
		FormDefDetailForm.show(a);
	}
};